package android.ijiajiao.server.impl;

import java.util.ArrayList;

import javax.servlet.http.Part;

import android.ijiajiao.dao.impl.IdentiDaoImpl;
import android.ijiajiao.server.IdentiServer;
import net.sf.json.JSONObject;

public class identiServerImpl implements IdentiServer {

	@Override
	public JSONObject realName(String name, String path, Part parts) {
		JSONObject reponseData = new JSONObject();
		boolean data = new IdentiDaoImpl().realName(name, path, parts);
		if (data == false) {
			reponseData.put("result", 0);
			reponseData.put("data", "添加用户认证失败");
		} else {
			reponseData.put("result", 1);
			reponseData.put("data", "添加用户认证成功");
		}

		return reponseData;
	}

	@Override
	public JSONObject realNameBack(String name, String path, Part parts) {
		JSONObject reponseData = new JSONObject();
		boolean data = new IdentiDaoImpl().realNameBack(name, path, parts);
		if (data == false) {
			reponseData.put("result", 0);
			reponseData.put("data", "添加用户认证失败");
		} else {
			reponseData.put("result", 1);
			reponseData.put("data", "添加用户认证成功");
		}

		return reponseData;
	}

	@Override
	public JSONObject edu(String name, String path, Part parts) {
		JSONObject reponseData = new JSONObject();
		boolean data = new IdentiDaoImpl().edu(name, path, parts);
		if (data == false) {
			reponseData.put("result", 0);
			reponseData.put("data", "添加用户认证失败");
		} else {
			reponseData.put("result", 1);
			reponseData.put("data", "添加用户认证成功");
		}

		return reponseData;
	}

	@Override
	public JSONObject teacher(String name, String path, Part parts) {
		JSONObject reponseData = new JSONObject();
		boolean data = new IdentiDaoImpl().teacher(name, path, parts);
		if (data == false) {
			reponseData.put("result", 0);
			reponseData.put("data", "添加图片认证失败");
		} else {
			reponseData.put("result", 1);
			reponseData.put("data", "添加图片认证成功");
		}

		return reponseData;
	}

	@Override
	public JSONObject quali(String name, String path, Part parts) {
		JSONObject reponseData = new JSONObject();
		boolean data = new IdentiDaoImpl().quali(name, path, parts);
		if (data == false) {
			reponseData.put("result", 0);
			reponseData.put("data", "添加图片认证失败");
		} else {
			reponseData.put("result", 1);
			reponseData.put("data", "添加图片认证成功");
		}

		return reponseData;
	}

	@Override
	public JSONObject identi(String name, String summary) {
		JSONObject reponseData = new JSONObject();
		boolean data = new IdentiDaoImpl().identi(name, summary);
		if (data == false) {
			reponseData.put("result", 0);
			reponseData.put("data", "添加用户认证失败");
		} else {
			reponseData.put("result", 1);
			reponseData.put("data", "添加用户认证成功");
		}

		return reponseData;
	}

	@Override
	public JSONObject realName(String name) {
		JSONObject reponseData = new JSONObject();
		ArrayList<String> data = new IdentiDaoImpl().realName(name);
		if (data.isEmpty()) {
			reponseData.put("result", 0);
			reponseData.put("data", "获取数据失败");
		} else {
			reponseData.put("result", 1);
			reponseData.put("data", data);
		}

		return reponseData;
	}

	@Override
	public JSONObject realNameBack(String name) {
		JSONObject reponseData = new JSONObject();
		ArrayList<String> data = new IdentiDaoImpl().realNameBack(name);
		if (data.isEmpty()) {
			reponseData.put("result", 0);
			reponseData.put("data", "获取数据失败");
		} else {
			reponseData.put("result", 1);
			reponseData.put("data", data);
		}

		return reponseData;
	}

	@Override
	public JSONObject edu(String name) {
		JSONObject reponseData = new JSONObject();
		ArrayList<String> data = new IdentiDaoImpl().edu(name);
		if (data.isEmpty()) {
			reponseData.put("result", 0);
			reponseData.put("data", "获取数据失败");
		} else {
			reponseData.put("result", 1);
			reponseData.put("data", data);
		}

		return reponseData;
	}

	@Override
	public JSONObject teacher(String name) {
		JSONObject reponseData = new JSONObject();
		ArrayList<String> data = new IdentiDaoImpl().teacher(name);
		if (data.isEmpty()) {
			reponseData.put("result", 0);
			reponseData.put("data", "获取数据失败");
		} else {
			reponseData.put("result", 1);
			reponseData.put("data", data);
		}

		return reponseData;
	}

	@Override
	public JSONObject quali(String name) {
		JSONObject reponseData = new JSONObject();
		ArrayList<String> data = new IdentiDaoImpl().quali(name);
		if (data.isEmpty()) {
			reponseData.put("result", 0);
			reponseData.put("data", "获取数据失败");
		} else {
			reponseData.put("result", 1);
			reponseData.put("data", data);
		}

		return reponseData;
	}

	@Override
	public JSONObject identi(String name) {
		JSONObject reponseData = new JSONObject();
		ArrayList<String> data = new IdentiDaoImpl().identi(name);
		if (data.isEmpty()) {
			reponseData.put("result", 0);
			reponseData.put("data", "获取数据失败");
		} else {
			reponseData.put("result", 1);
			reponseData.put("data", data);
		}

		return reponseData;
	}

}
